<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	May 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/candidates/tmpl/mycv.php
 ^ 
 * Description: template view my cv
 ^ 
 * History:		NONE
 ^ 
 */
 
 defined('_JEXEC') or die('Restricted access');
   global $mainframe;
  $document =& JFactory::getDocument();

  /*$document->addScript( 'components/com_wrecruit/js/jquery-1.7.2.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery-ui.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery.uniform.js' );
  $document->addScript( 'components/com_wrecruit/js/scripts.js' );*/
  $document->addScript( 'components/com_wrecruit/js/popup.js' );
  $document->addStyleSheet('components/com_wrecruit/css/popup.css');
  $document->addStyleSheet('components/com_wrecruit/css/chosen/chosen.css');
  $candidate = $this->getModel('wrecruit', 'WRecruitModel');
  $user	=& JFactory::getUser();
  if(isset($user->id) && $user->id == 0 || $user->id == ''){
	   $app =& JFactory::getApplication(); 
	   $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );
	  return;
  }else{
  	$candidateObj = $candidate->getAllCandidatesInfor($user->id);
	if( !$candidateObj ){
		$app =& JFactory::getApplication(); 
       //add a message to the message queue
        $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );

		return;
	}
	
  }
  $com_base = "components/com_wrecruit/";
  if(JRequest::getVar('newcv_popup_required')!=""){
    $scriptDec = "
	jQuery(function(){
		jQuery('#post-cv-leading-page').trigger(\"click\");	
	});
    
  ";
  $document->addScriptDeclaration ($scriptDec);
 }
  
?>


				<div class="box-list-job">
					<div class="job-seeker-panel">
						<?php include('components/com_wrecruit/views/candidates/tmpl/menuLeft.php');?>
					</div>
					<div class="job-seeker-right">
						<div class="head-title">
						<h2>My CV</h2>
                        <div style="float: left; margin: -23px 22px -12px 0px; width: 528px; position:relative; height: 55px;">
                      
                                <div class="wrapp-btn">
                                    <span class="btn-left"><span class="btn-right"><input type="submit" id="post-cv-leading-page" class="wpopup btn" value="Add new CV" border="none" /> &nbsp;</span></span>
                               </div>
                          
                         </div>
						</div>
                        
                        
                        
						<?php 
						$page = JRequest::getVar("page");
						$number_show = 2;
						if($page > 1){
							$p	=	$page;
						}
						else{
							$p	=	1;
						}
						$start	=	($p-1)*$number_show;
						$param['start']= $start;
						$param['number_show'] = $number_show ;
					
						if ($data = $candidate->getCvListForCandidate($candidateObj->uid,$param)) {
							$n = count($data);
							for ($i=0; $i< $n; $i++) {
								?>
								    <?php 
										$page ='buildcv';
										$page =  (($data[$i]->RESUME_TYPE)==0)?'buildcv':'editcvuploadcopyandpast';
										$viewcv ='viewcv';
										$viewcv =  (($data[$i]->RESUME_TYPE)==0)?'viewcv':'viewcvfile';
									 ?>
                                    <div class="divwrapp-mycv">
                                    <!--<strong>Flash Game Developer</strong>-->
                                    <a href="#" title="" class="cv-delete"><img alt="" class="cv-delete cv_item_remove"  id="cv_remove_byid_<?php echo $data[$i]->ID; ?>" src="<?php echo $com_base;?>images/delete.gif" width="20" height="20"/></a>
                                    <a href="<?php echo JURI::base();?>index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=<?php echo $page;?>&Itemid=<?php echo JRequest::getVar('Itemid'); ?>&id=<?php echo $data[$i]->ID; ?>" title="" class="cv-edit old_cv_item_edite" id="old_cv_edit_byid_<?php echo $data[$i]->ID; ?>"><img alt="" src="<?php echo $com_base;?>images/edit.gif" width="20" height="20" style="float:right; margin-right:3px;"/></a>
                                    <a href="<?php echo JURI::base();?>index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=<?php echo $viewcv;?>&Itemid=<?php echo JRequest::getVar('Itemid'); ?>&id=<?php echo $data[$i]->ID; ?>" title="" class="cv-edit"><img alt="" src="<?php echo $com_base;?>images/view.gif" width="20" height="20" style="float:right; margin-right:3px;"/></a>
                                    <div id="pic-pro">
									 
									 <a href="<?php echo JURI::base();?>index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=candidateprofile&Itemid=<?php echo JRequest::getVar('Itemid'); ?>&id=<?php echo $data[$i]->ID; ?>">
                                      <?php
									  if(file_exists(JPATH_SITE.DS.'wrecruitdata'.DS.'photo'.DS.$candidateObj->photo)){
									  ?>
										<img height="100" width="100" src="<?php echo JURI::base();?>/wrecruitdata/photo/<?php echo $candidateObj->photo; ?>" 
						alt="<?php echo $candidateObj->firstname." ".$candidateObj->lastname;?>">
									  <? } ?>
									 </a>
                                    </div>
                                    <h4 class="txt-mycv">
                                    <a href="<?php echo JURI::base();?>index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=<?php echo $viewcv;?>&Itemid=<?php echo JRequest::getVar('Itemid'); ?>&id=<?php echo $data[$i]->ID; ?>"
                                     title="<?php echo $data[$i]->APPLICATION_TITLE;?>"><?php echo $data[$i]->APPLICATION_TITLE;?></a></h4>
                                    <p><div class="txt-mycv-b"><span>Industry:</span> <?php echo $data[$i]->INDUSTRY;?></div>
                                     <div class="txt-right"><a href="#" title="">Top up in search</a></div></p>
                                    <p><div class="txt-mycv-b"><span>Salary:</span> <?php echo $data[$i]->SALARY;?></div></p>
                                    <p><div class="txt-mycv-b"><span>Posted date:</span> <?php echo $data[$i]->POST_DATE;?></div>&nbsp;</p>
                                    <p><strong class="txt-right"><span style="font-weight:normal;">Note:&nbsp;</span><?php echo (($data[$i]->RESUME_TYPE)==1)?'Copy Paste':'Build CV';?></strong></p>
                                    </div>
                                <?php
							}
						}
				$total  = $candidate->getCvListForCandidateTotal($candidateObj->uid);
				if($total && $total > $param['number_show'] ){		
						?>
			    <div class="pagination" id="mycv-navigation">
					<?php 
					
					if($p!=1){?>
			    	<a class="link-first" href="<?php echo JURI::base();?>index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=mycv&sorted_field=<?php echo JRequest::getVar('sorted_field');?>&Itemid=<?php echo JRequest::getVar('Itemid');?>&page=<?php echo $p-1;?>">Previous</a>
			    	<?php }
						$count = 0;
						for($i=0;$i<$total;$i=$i+$number_show){
							$count++;
						  if($count!=$p){
						?>
							
					   		 <a href="<?php echo JURI::base();?>index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=mycv&sorted_field=<?php echo JRequest::getVar('sorted_field');?>&Itemid=<?php echo JRequest::getVar('Itemid');?>&page=<?php echo ($i/$number_show)+1;?>"><? echo ($i/$number_show)+1;?></a><?php 
						
						  }else{ ?>
							 <a style="text-decoration:none !important; color:#000 !important;"><? echo ($i/$number_show)+1;?></a>
						 <?php }
						}
						if($p!=$count){?>
					   		<a class="link-next" href="<?php echo JURI::base();?>index.php?option=com_wrecruit&c=wrecruit&view=candidates&layout=mycv&sorted_field=<?php echo JRequest::getVar('sorted_field');?>&Itemid=<?php echo JRequest::getVar('Itemid');?>&page=<?php echo $p+1;?>">Next</a>
					<?php
						}
					?>					
				</div>
				<?php }?>
					</div>
				</div>
				
				<!--<div class="box-banner-bottom">					
					<img src="<?php echo $com_base;?>images/banner-avertise-bottom.jpg" alt="" title="" width="745" height="122" />
				</div>-->
	  <!--popup content-->
        <div id="popupContainer" class="hidden" style="text-align:left;">
            <a id="close" class="hidden" title="close popup"></a>   
            <center>
            <form action="index.php" method="post">
            <table border="0">
            	<tr>
                	<td><input type="text" class="text" value="<?php echo $candidateObj->EMAIL;?>" name="mails" /></td>
                    <td></td>
                </tr>
                <tr>
                	<td colspan="2" align="right"> <input type="submit" value="Save" /></td>
                </tr>
            </table>
            </form>
            </center>
             
        </div>
        <div id="overlayEffect">
        </div>
       <!--end popup content--> 
